//
//  FMPublicTopicViewController.m
//  PsychologyFM
//
//  Created by zhang on 16/1/15.
//  Copyright © 2016年 ZhangLuDu. All rights reserved.
//

#import "FMPublicTopicViewController.h"

@interface FMPublicTopicViewController ()<UITextViewDelegate>
@property (nonatomic, strong) UIView *nagevitionBarView;
//发表的标题
@property (nonatomic, strong) UITextField *titleFeild;
//发表的内容
@property (nonatomic, strong) UITextView *contentFeild;
//发表内容里面的占位符
@property (nonatomic, strong) UILabel *lable;
@end

@implementation FMPublicTopicViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = FMWhite;
    
    [self addNageVitionBar];
    [self addSubviews];
}
#pragma mark 添加nagevitonBar
- (void)addNageVitionBar{
    self.nagevitionBarView = [[UIView alloc]initWithFrame:CGRectMake(0, 20, kScreenWidth, 44)];
    //    添加返回按钮
    UIButton *cancelButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    cancelButton.frame = CGRectMake(20, 10, 30, 30);
    [cancelButton setImage:[UIImage imageNamed:@"cross1@2x"] forState:(UIControlStateNormal)];
    [cancelButton addTarget:self action:@selector(cancelButton:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.nagevitionBarView addSubview:cancelButton];
    [self.view addSubview:_nagevitionBarView];
    UILabel *titleLable = [[UILabel alloc]initWithFrame:CGRectMake((kScreenWidth - 40) / 2, 0, 40, 40)];
    titleLable.text = @"评论";
    
    [self.nagevitionBarView addSubview:titleLable];
    //添加提交按钮
    UIButton *commiteButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    commiteButton.frame = CGRectMake(kScreenWidth - 40, cancelButton.top, 30, cancelButton.height);
    [commiteButton setImage:[UIImage imageNamed:@"tick@2x"] forState:(UIControlStateNormal)];
    [self.nagevitionBarView addSubview:commiteButton];
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 43, kScreenWidth, 1)];
    view.backgroundColor = FMGray;
    [self.nagevitionBarView addSubview:view];
}
- (void)cancelButton:(UIButton *)button{

    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)addSubviews{

    self.titleFeild = [[UITextField alloc]initWithFrame:CGRectMake(kMartin10, 64, kScreenWidth - 20, 40)];

    self.titleFeild.placeholder = @"标题(30字内)";
    
    [self.view addSubview:_titleFeild];
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 105, kScreenWidth, 1)];
    view.backgroundColor = FMRed;
    [self.view addSubview:view];
    
    self.contentFeild = [[UITextView alloc]initWithFrame:CGRectMake(kMartin10, 106, kScreenWidth - kMartin20, kScreenHeight - 64 - 40)];
    self.contentFeild.delegate  =self;
    self.contentFeild.font = [UIFont systemFontOfSize:16];
    [self.view addSubview:_contentFeild];
    
    self.lable = [[UILabel alloc]initWithFrame:CGRectMake(kMartin20, 106 + kMartin5, 100, kMartin20)];
    self.lable.text = @"我想要说";
    self.lable.textColor = FMGray;
    [self.view addSubview:_lable];
}

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
 //[self.lable removeFromSuperview];
    return YES;
}
- (void)textViewDidChange:(UITextView *)textView{
    if (textView.text.length == 0) {
        self.lable.hidden = NO;
    }else{
    self.lable.hidden = YES;
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
